<?php

/**
Task:
Make a function that will calculate the power of a number x to index y, but you cannot use

multiplication! to make it a bit simpler please take into account only natural numbers.
*/
function calculatePower($base, $index)
{
    if (! is_int($base)) {
        throw new InvalidArgumentException('calculatePower() function only accepts integers. Exponential base argument was: ' . $base);
    }
    if (! is_int($index)) {
        throw new InvalidArgumentException('calculatePower() function only accepts integers. Exponential index argument was: ' . $index);
    }
    return pow($base, $index); // x^y
}




$x = 3;
$y = 2;

try {
    echo $x . "^" . $y . "=" . calculatePower($x, $y) . "\n";
} catch (Exception $e) {
    echo $e->getMessage();
}
